#include "visiblebutton.h"
#include <QStyle>
#include <QDebug>
VisibleButton::VisibleButton(QWidget *parent):QPushButton(parent)
{
    state_ = UNSelected;
    this->setProperty("state","unselected");//图标默认为未选中状态
    qDebug() << "默认为未选中状态";
}

VisibleButton::~VisibleButton()
{

}

void VisibleButton::enterEvent(QEvent *ev)
{
    qDebug() << "鼠标进入，选中状态，刷新样式";
    state_ = Selected;
    this->setProperty("state","selected");//图标切换为选中状态
    this->style()->polish(this);//刷新样式
    this->update();

    QPushButton::leaveEvent(ev);
}

void VisibleButton::leaveEvent(QEvent *ev)
{
    qDebug() << "鼠标离开，未选中状态，刷新样式";
    state_ = UNSelected;
    this->setProperty("state","unselected");//图标切换为未选中状态
    this->style()->polish(this);//刷新样式
    this->update();

    QPushButton::enterEvent(ev);
}
